<%--
  Created by IntelliJ IDEA.
  User: yinshankun
  Date: 2020/11/2
  Time: 11:17尹山坤
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link href="<%=path%>/ysk/css/stylereg.css" rel='stylesheet' type='text/css' />
<script type="text/javascript" src="<%=path%>/ysk/js/jquery-3.5.1.min.js"></script>
<html>
<head>

    <title>登陆</title>
    <style type="text/css">

        #reg2{background-image: url("<%=path%>/ysk/images/bg.jpg")}
        #reg3{
            margin-top: 1px;
           width: 190px;
        }
        #reg4{
            margin-right: 50px;
            padding-top: 10px;
            width: 100px;
            height: 50px;
            float:right;
        }
        #btn{
            width: 80px;
            height: 40px;
            background-color: orange;
        }
        #reg5{
            margin-left: -250px;
            font-size: 20px;
            color: black;


        }
        #reg6{
            width: 15px;
            height: 15px;

        }
        #shouji{
            margin-left: 300px;
            margin-top: -50px;

        }
        #forgetpassword{
            width: 100px;
            height: 50px;
            margin-left: 320px;
            font-size: 20px;

        }
        #cuo{
            margin-left: 580px;
            font-size: 30px;


        }
        #reg9{
            margin-left: 360px;
            margin-top: 50px;
            font-size: 20px;
        }

    </style>
</head>
<body>
<h1>Sign in</h1>
<c:if test="${1 eq param.errMes}">
    <span  id="cuo"  style="color:black  "  >用户名或者密码错误</span>
</c:if>
<c:if test="${2 eq param.errMes}">
    <span   id="cuo" style="color:red  "  >验证码错误</span>
</c:if>
<div id="reg2" class="app-cam">
    <div class="cam"><img src="<%=path%>/ysk/images/cam.png" class="img-responsive" alt="" /></div>
    <form method="post" id="loginform" action="<%=path%>/loginysk">
        <input type="text" placeholder="账号" name="userName" class="text"   >
        <input type="password" placeholder="密码" name="userPass"  >

        <input type="text" placeholder="验证码" class="yzm" name="code" id="reg3">
      <img  id="reg4" src="<%=path%>/code" class="code">
        <div id="reg5"><input id="reg6" name="rememberMe"  type="checkbox"><label for="reg6">记住我</label></div>

        <div id="forgetpassword"><a href="<%=path%>/forgetpager">忘记密码？</a></div>
        <div class="submit"><input type="button" id="btn"  value="登录" ></div>
       <div id="shouji"><a href="<%=path%>/loginphone">用手机号登陆</a></div>
        <div id="reg9" ><a href="<%=path%>/registerpager">注册</a></div>


    </form>
</div>

</body>
</html>
<!--更换验证码-->
<script type="text/javascript">
$(function () {
$(".code").click(function () {
        $(this).attr("src","<%=path%>/code?rand="+Math.random());
 })
//判断验证码是否正确
    $("#btn").click(function () {
        var code=$(".yzm").val();
        $.ajax({
            url:"<%=path%>/checkcode",
            type:"post",
            data:{code,code},
            async:false,
            success:function (mes) {
                if(mes!="pass"){
                    $(".yzm").val("");
                    $(".yzm").attr("placeholder","验证码错误，请重新输入")
                    $(".code").attr("src","<%=path%>/code?rand="+Math.random());
                    $(".yzm").select();
                    return;
                }
                else{
                        $("#loginform").submit();
                }
            }


        })
    })

 })



</script>